﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Security.Cryptography;
using Rally_MvvmC.Library;
using System.Configuration;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            var str = "AvLiL161jxZQgT4t4X7drYki2VK0OKXXnM3cXCe0ZW7QQiDOovm/c0qnz/L1AaWJ63Lbe0+Qdc0vwBGcNeJY5wHkNO0lKFi9B1Dbw2+EnMekaCp3whEmOPq/cHDz4AY0JmeXP4G5wxBWW1sy9lrW8pukcZjz/KDBiw6xAUEfBYL+vjitt8+Bh00dg1Ayar4B7GAx++V/8/eWUgmTBkkuH0G6rb04rr1e/c3B20Wj4Y6IZTkDUxLYvoS5heD3NBwsxauMXL0SphrQm65A6FjUyzuDdaAOffb4rb7i6ANAQXc5E69eCyhbYi3EOty3fq4IAzoTl348oU3q9kYTnVqd3Q==";
            var len = str.Length;
            var encryptor = new Encryptor(ConfigurationManager.AppSettings["TextSet"], ConfigurationManager.AppSettings["AlternateTextSet"]);
            var xyz = encryptor.Encrypt("Here is my text");
            var xyz2 = encryptor.Decrypt(xyz);
            
            var str2 = Reverse(str.Substring(str.Length / 2) + str.Substring(0, str.Length / 2));
            var text = CreateSalt(256);
            var bytes = Encoding.UTF8.GetBytes(str2);
        }

        private static string CreateSalt(int size)
        {
            //Generate a cryptographic random number.
            RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider();
            byte[] buff = new byte[size];
            rng.GetBytes(buff);

            // Return a Base64 string representation of the random number.
            return Convert.ToBase64String(buff);
        }

        public static string Reverse(string text)
        {
            if (text == null) return null;

            // this was posted by petebob as well 
            char[] array = text.ToCharArray();
            Array.Reverse(array);
            return new String(array);
        }
    }
}
